class SecurityController < ApplicationController
  include Security::Session::Configure
  def login
    case request.method
      when :post
        if store_session_user(User.authenticate(params['login'],params['password']))
          flash[:notice] = "Login successful"
          reset_permissions_from_login
          goto_url = get_continuation_url
          redirect_to(goto_url)
          return
        else
          flash[:error] = "Login unsuccessful"
        end
    end
  end

  def logout
    reset_session
    redirect_to(home_url)
  end

  private
    def get_continuation_url
      rvalue = home_url
      if session[:continue_on]
        rvalue = session[:continue_on]
        session[:continue_on] = nil
      end
      rvalue 
    end
end
